package com.aspose.cells;

class zabf extends CollectionBase {
   public zabd a(int var1) {
      return (zabd)this.a.get(var1);
   }

   boolean a(StringBuilder var1) {
      if (var1.length() != 0) {
         this.b(var1);
      } else if (this.getCount() == 0) {
         throw new CellsException(5, "Invalid formula.");
      }

      zabd var2 = (zabd)this.a.get(this.getCount() - 1);
      if (var2.i() == 2) {
         throw new CellsException(5, "Invalid formula.");
      } else {
         this.a.remove(this.getCount() - 1);
         zabd var3 = new zabd();
         var3.a(6);
         var3.a("%");
         var3.a(zasg.c);
         var3.a(var2);
         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var3);
         return true;
      }
   }

   void a(StringBuilder var1, String var2, boolean var3) {
      zabd var4 = new zabd();
      var4.a(2);
      var4.a(var2);
      var4.b = 3;
      if (var1.length() != 0) {
         this.b(var1);
      } else if (this.getCount() == 0) {
         var4.a(6);
         if (var3) {
            var4.a(zasg.a);
         } else {
            var4.a(zasg.b);
         }
      } else {
         zabd var5 = (zabd)this.a.get(this.getCount() - 1);
         switch(var5.i()) {
         case 2:
            var4.a(6);
            if (var3) {
               var4.a(zasg.a);
            } else {
               var4.a(zasg.b);
            }
            break;
         case 6:
            if (var5.b == 3) {
               var4.a(6);
               if (var3) {
                  var4.a(zasg.a);
               } else {
                  var4.a(zasg.b);
               }
            } else if (var3) {
               var4.a(zasg.f);
            } else {
               var4.a(zasg.g);
            }
            break;
         default:
            if (var3) {
               var4.a(zasg.f);
            } else {
               var4.a(zasg.g);
            }
         }
      }

      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var4);
   }

   boolean a(StringBuilder var1, String var2, int var3, byte[] var4) {
      if (var1.length() != 0) {
         this.b(var1);
      } else if (this.getCount() == 0) {
         throw new CellsException(5, "Invalid formula.");
      }

      zabd var5 = (zabd)this.a.get(this.getCount() - 1);
      switch(var5.i()) {
      case 2:
         throw new CellsException(5, "Invalid formula.");
      case 6:
         if (var5.b == 3) {
            throw new CellsException(5, "Invalid formula.");
         }
      default:
         zabd var6 = new zabd();
         var6.a(var2);
         var6.a(var4);
         var6.a(2);
         var6.b = var3;
         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var6);
         return true;
      }
   }

   void a(zabd var1) {
      if (this.getCount() != 0) {
         for(int var2 = this.getCount() - 1; var2 >= 0; --var2) {
            zabd var3 = (zabd)this.a.get(var2);
            if (var3.i() != 6 || var3.b != 3) {
               break;
            }

            var3.a(var1);
            var1 = var3;
            var3.b = 0;
            this.removeAt(var2);
         }
      }

      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var1);
   }

   void b(StringBuilder var1) {
      zabd var2 = new zabd();
      var2.a(com.aspose.cells.b.a.zr.a(var1));
      var1.delete(0, 0 + var1.length());
      var2.a(1);
      if (this.getCount() != 0) {
         boolean var3 = true;

         for(int var4 = this.getCount() - 1; var4 >= 0; --var4) {
            zabd var5 = (zabd)this.a.get(var4);
            if (var5.i() != 6 || var5.b != 3) {
               break;
            }

            if (!var3) {
               var5.a(var2);
            } else {
               if ("-".equals(var5.b()) && zapb.b(var2.b())) {
                  var5.a(1);
                  var5.a("-" + var2.b());
                  var5.a((byte[])null);
               } else {
                  var5.a(var2);
               }

               var3 = false;
            }

            var5.b = 0;
            var2 = var5;
            this.removeAt(var4);
         }
      }

      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var2);
   }

   // $FF: synthetic method
   public Object get(int x0) {
      return this.a(x0);
   }
}
